package com.xishu.util;

import org.apache.commons.codec.binary.Hex;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.security.MessageDigest;

public class Md5 {
    private static Logger logger = LoggerFactory.getLogger(Md5.class);

    /**
     * 做签名
     *
     * @param content
     * @return
     */
    public static String md5(String content) {
        MessageDigest messageDigest;
        String encdeStr = "";
        try {
            messageDigest = MessageDigest.getInstance("MD5");

            byte[] hash = messageDigest.digest(content.getBytes("UTF-8"));
            encdeStr = Hex.encodeHexString(hash);
            logger.debug("input is {},sha256 str is {}", content, encdeStr);
        } catch (Exception e) {
            logger.error("e", e);
        }

        return encdeStr;
    }
}
